package com.ljx.offer;

import org.junit.Test;

/**
 * @author 李捷禧
 * Date: 2023/3/30
 * ClassName: C_46
 */

public class C_46 {
    /**
     * 使用余数从右到左
     * @param num
     * @return
     */
    public int translateNum(int num) {
        if(num < 10) return 1;
        int a = 1,b =1,c,x ,y = num % 10;
        while (num != 0){
            num /= 10;
            x = num % 10;
            if(x*10 + y >= 10 && x*10 + y <= 25){
                c = a + b;
            }else {
                c = a;
            }
            b = a;
            a = c;
            y = x;
        }
        return a;
    }

    @Test
    public void test(){
        System.out.println(translateNum(123456));

    }
}
